<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加页面</title>
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.7/dist/css/layui.css">
</head>
<body>
<form class="layui-form" id="commentForm">
    <div class="layui-form-item">
        <label class="layui-form-label">节点名称</label>
        <div class="layui-input-block">
            <input type="text" name="a_name" lay-verify="title" autocomplete="off" placeholder="请输入节点名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">路由别名</label>
        <div class="layui-input-block">
            <input type="text" name="a_fun" lay-verify="required" lay-reqtext="别名岂能为空？" placeholder="请输入"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否菜单</label>
        <div class="layui-input-block">
            <input type="checkbox" checked="" name="is_status" lay-skin="switch" lay-filter="switchTest"
                   lay-text="ON|OFF">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">加入时间</label>
        <div class="layui-input-block">
            <input type="datetime-local" name="a_add" lay-verify="title" autocomplete="off" placeholder="请输入节点名称"
                   class="layui-input">
        </div>
    </div>
    <p>
        <input class="submit" type="submit" value="Submit">
    </p>

</form>
</body>
</html>
<!-- 引入 layui.js -->
<script src="//unpkg.com/layui@2.6.7/dist/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<script>
    $.validator.setDefaults({
        submitHandler: function () {
            alert("提交事件!");
        }
    });
    $().ready(function () {
        $("#commentForm").validate({
            rules: {
                'a_name': {
                    required: true,
                },
                'a_fun': {
                    required: true,
                }
            },
            messages: {
                'a_name': {
                    required: "<span style='color: red'>不能为空!</span>",
                },
                'a_fun': {
                    required: "<span style='color: red'>不能为空!</span>",

                }
            }
        });
    });

</script>
